import useDictStore from '@/store/modules/dict'
import { dsData } from "@/api/dev/modelData";

/**
 * 获取字典数据
 */
export function useDataset(dsCode) {
  const res = ref({});
  return (() => {
    res.value = [];
    let key='ds_'+dsCode;
    const dicts = useDictStore().getDict(key);
    if (dicts) {
      res.value = dicts;
    } else {
      dsData(dictType).then(resp => {
        res.value = resp.data;
        useDictStore().setDict(key, res.value);
      })
    }
    return toRefs(res.value);
  })()
}